'use strict';
import React, {Component} from 'react'
import {Link, hashHistory} from 'react-router'
import {R_header} from './common/index';



export default class SelectionCycle extends Component {
    constructor(props) {
        super(props);
        this.state = {
            select: this.props.selectCysle,
            show:this.props.show
        }
    }
    componentDidMount() {

    }
    /**
     * 点击周期
     * @returns {XML}
     */
    setCycle(index){
        this.props.setDisCycle(index);
    }
    componentWillReceiveProps() {
        setTimeout(() => {
            this.setState({show: this.props.show,select:this.props.selectCysle});
        }, 0)
    }
    /**
     * 点击返回
     * @returns {XML}
     */
    goReturn(){
        this.setState({show:false});
    }
    render() {
        let select = this.state.select.split(',');
        return (
            <div className={this.state.show==true?'cycle_page':'cycle_page hide'}>
                <R_header addFn={this.goReturn.bind(this)} title="选择周期" left="1" />
                <div className="cycle_list">
                    <div className={select[0]=='1'?"select":""} onClick={this.setCycle.bind(this,0)}>
                        每周一
                        <span className="img"/>
                    </div>
                    <div className={select[1]=='1'?"select":""} onClick={this.setCycle.bind(this,1)}>
                        每周二
                        <span  className="img"/>
                    </div>
                    <div className={select[2]=='1'?"select":""} onClick={this.setCycle.bind(this,2)}>
                        每周三
                        <span  className="img"/>
                    </div>
                    <div className={select[3]=='1'?"select":""} onClick={this.setCycle.bind(this,3)}>
                        每周四
                        <span  className="img"/>
                    </div>
                    <div className={select[4]=='1'?"select":""} onClick={this.setCycle.bind(this,4)}>
                        每周五
                        <span  className="img"/>
                    </div>
                    <div className={select[5]=='1'?"select":""} onClick={this.setCycle.bind(this,5)}>
                        每周六
                        <span  className="img"/>
                    </div>
                    <div className={select[6]=='1'?"select":""} onClick={this.setCycle.bind(this,6)}>
                        每周日
                        <span  className="img"/>
                    </div>
                </div>
            </div>
        )
    }
}
